package com.guanyong.admin.controllers.page;

import com.guanyong.model.BannerListModel;
import com.guanyong.services.BannerListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by mxk on 2017/9/22.
 */
@Controller
@RequestMapping("/page/banner")
public class BannerPage extends baseController{

    @Autowired
    BannerListService bannerListService;

    @RequestMapping({"/list"})
    String getAllBannerList(
            HttpServletRequest request) {
        return  "/banner/list";
    }

    @RequestMapping({"/add"})
    String addbanner(HttpServletRequest request) {
        return  "/banner/add";
    }

    @RequestMapping({"/update"})
    String updatebanner(Model model, HttpServletRequest request) {


        String fid=request.getParameter("fid");
        Integer Nfid=Integer.parseInt(fid);

        BannerListModel bannerListModel =bannerListService.GetBannerByid(Nfid);
        if (bannerListModel!=null){
            model.addAttribute("bannermodel",bannerListModel);
            return  "/banner/update";
        }
        else{
            return "errorPage/500";
        }

    }
}
